clear;close all;
global alpha
alpha=[-20];
h_all=[0.1 0.2];
y0=1;x0=0;
x_range=[0 4.1];

for ii=1:length(h_all)
h=h_all(ii);
[ y{ii},x{ii} ] = RK_ode44( @y_derivation,y0,x0,h,x_range );
y_exact{ii} = y_exact_func( x{ii} )
end

figure;hold on;
% draw marker and line sperately: h is small, and too many sample points
% draw markers with down-sampling
Marker_list={'+','o','^','V'};
for ii=1:length(h_all)
hdl=plot(x{ii}(1:1:end),y{ii}(1:1:end),['b' Marker_list{ii}]);
set(hdl,'DisplayName',['R-K Method: h = ' num2str(h_all(ii))]);
hdl=plot(x{ii}(1:10:end),y_exact{ii}(1:10:end),['r' Marker_list{ii}]);
set(hdl,'DisplayName',['Exact: h = ' num2str(h_all(ii))]);
end
legend('Show');

% draw lines
for ii=1:length(h_all)
plot(x{ii},y{ii},['b-']);
plot(x{ii},y_exact{ii},['r:']);
end
xlim(x_range);
ylim([0 5]);
xlabel('x');
ylabel('y');
title(['Runge Kutta Methods: alpha=' num2str(alpha)]);

figure;hold on;
% draw marker and line sperately: h is small, and too many sample points
% draw markers with down-sampling
Marker_list={'+','o','^','V'};
for ii=1:length(h_all)
hdl=plot(x{ii}(1:1:end),abs(y{ii}(1:1:end)-y_exact{ii}(1:1:end)),['b' Marker_list{ii}]);
set(hdl,'DisplayName',['R-K Method error: h = ' num2str(h_all(ii))]);
end
legend('Show');

% draw lines
for ii=1:length(h_all)
plot(x{ii},abs(y{ii}-y_exact{ii}),['b-']);
end
xlim(x_range);
xlabel('x');
ylabel('y');
title(['Runge Kutta Methods: alpha=' num2str(alpha)]);

if 0
x_all=0:0.3:3;
for ii=1:length(h_all)
    for iiY=1:length(y{ii})
        find()
    end
plot(x{ii},abs(-y_exact{ii}),['b-']);
end
plot(x{1},'x')
data_out1=[x{1}(1:4:end);y{1}(1:4:end);y_exact{1}(1:4:end)]
data_out2=[x{2}(1:2:end);y{2}(1:2:end);y_exact{2}(1:2:end)]
data_out=[data_out1;data_out2];
end